|
|
|
|
|
|
|
Figure 13.6
Control array elements
can be added at runtime. |
|
|
|
|
|
|
|
|
Removing Controls at Runtime |
|
|
|
|
|
|
|
|
Just as you may need to add one or more controls at runtime, you might also need to remove one or more controls at runtime as well. To remove a control, use the Unload statement. As with the Load statement, you need to specify the name of the control and its index, as shown here: |
|
|
|
|
CAUTION
|
|
|
|
|
You can use Unload only with controls that were created at runtime. You cannot use Unload with any control array elements that were created at design time . |
|
|
|
|
|
|
|
|
|
|
You discovered earlier that you could use control arrays to create a generic data entry form. This form would examine the structure of the recordset and then create controls to handle all the fields in the recordset. In this section, you learn how such a form would work. |
|
|
|
|
|
|
|
|
To keep it simple, the form will have two arraysone for the labels describing the fields and one for text boxes to hold the field values. To start the setup of the form, add a label array and a text box array to a form, as shown in Figure 13.7. |
|
|
|
|
|
|
|
|
|
To create array elements rather than separate controls, set the Index property of your label and text box to 0.  |
|
|
|
|
|
|
|
|
|
|
You also need to add a Data control to the form to provide the recordset for the form to use. You learn about the Data control and related data-bound controls in Chapter 25, "The Data Control and Data-Bound Controls." |
|
|
|
|
|